#include<bits/stdc++.h>
#define int long long 
using namespace std;

const int maxn=1e5+10;
int l, r;

void solve(){
	cin>>l>>r;
	if(r<2*l){
		cout<<0<<'\n';
		return;
	}
	int cnt=r-2*l+1;
	int mx=r-2*l;
	int ans = cnt + (mx*(mx+1))/2;
	cout<<ans<<'\n';
}


signed main(){
	ios::sync_with_stdio(0), cin.tie(0),cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		//TODO
		solve();
	}
	return 0;
}
